//
//  ILBindObject.h
//  IMILabKit
//
//  Created by Roffa Zhou on 2022/4/2.
//

#import <Foundation/Foundation.h>

#if __has_include(<IMILabSDK_BindCommon/IMILabSDK_BindCommon.h>)
#import <IMILabSDK_BindCommon/ILBindDefine.h>
#import <IMILabSDK_Ble/ILBleObject.h>

#else
#import "ILBindDefine.h"
#import "ILBleObject.h"

#endif

NS_ASSUME_NONNULL_BEGIN

@interface ILBindObject : NSObject
@property(nonatomic, strong)ILBleObject *bleAdapt;      //蓝牙绑定类，当绑定linType类型为 ILLinkTypeBLE_1,ILLinkTypeBLE_2时

@property(nonatomic, copy)IL_Bind_Discovery_Block _Nullable discoveryBlock;  //发现周围设备回调
@property(nonatomic, copy)IL_Bind_Error_Block _Nullable bindErrorBlock;      //绑定错误更新回调
@property(nonatomic, copy)IL_Bind_Mode_Block _Nullable  bindStateBlock;      //绑定状态更新回调
@property(nonatomic, copy)IL_Bind_Api_Succ_Block _Nullable bindApiBlock;    //绑定最后一步的绑定网络请求API成功，会响应此block,抛出网络返回的内容。mode_1绑定方式时，整个绑定流程未完成，流程状态监听bindStateBlock。mode_2绑定方式时，此时整个绑定流程已经完毕
//重试回调,内部使用
@property(nonatomic, copy, nullable)ILBindRetryBlock retryBlock;
@property(nonatomic, copy, readonly)NSString *__nullable iotId;      //如绑定成功，此值会有值，返回设备的设备id
@property(nonatomic, copy, readonly)NSString *__nullable deviceName;      //如绑定成功，此值会有值，返回设备名称


/// 开始发现设备,这会发现周围的指定类型的所有可被SDK识别的设备
/// @param deviceType 待发现的设备类型
/// 周围的有线设备 ILDiscoryDeviceTypeWiredDevice
/// 周围的蓝牙设备 ILDiscoryDeviceTypeBLEDevice
/// @param timeout 超时时间
- (void)startDiscoveryDevice:(ILDiscoveryDeviceType)deviceType
          timeout:(NSTimeInterval)timeout;
/// 开始配网
/// @param device 设备
- (void)startActivateDevice:(ILBindDeviceModel*)device;
/// 中止绑定流程
- (void)stop;
/// 从错误处重试绑定
- (void)retryBind;

//MARK: 蓝牙绑定相关
/// 获取绑定错误状态,  如蓝牙相关状态
/// @author rf/2022-03-22
- (ILBindErrorModel*)getBindError;
/// 获取绑定当前状态
/// @author rf/2022-03-25
- (ILBindModeModel*)getBindMode;

/// 获取当前正在绑定的设备
- (ILBindDeviceModel*)getCurrentDevice;
@end

NS_ASSUME_NONNULL_END
